package studentinformationmanagementsystem.test;

import org.junit.Test;
import studentinformationmanagementsystem.entity.Page;
import studentinformationmanagementsystem.entity.Student;
import studentinformationmanagementsystem.service.StudentService;
import studentinformationmanagementsystem.service.impl.StudenServiceImpl;
import studentinformationmanagementsystem.utils.GetMD5;
import studentinformationmanagementsystem.utils.TimeCycle;


import java.text.ParseException;
import java.util.List;
import java.util.Map;

/**
 * @author 苗庆
 * @version 1.0
 * 学生测试类
 */
public class StudentTset {

 StudentService studenService =new StudenServiceImpl();


    /**
     * 添加测试
     */
    @Test
   public void register() throws ParseException {
        for (int i = 0; i <1 ; i++) {

            String a="zxymq1314";
            String s = GetMD5.string2MD5(a);

            Student student = new Student(null, "20181041352","汪洋","350181200004081830","男",TimeCycle.time("2000-09-07"),"汉","中共党员",
                    "20210404_202411_014564_峡谷狂飙_Zxy男朋友.jpg","18805952390","2296877874@qq.com","计算机科学与技术(1)班","计算机科学与技术",
                    "数学与计算学院","福建厦门","李小李","13600904451","四川成都",s,TimeCycle.time("2018-09-07"),0);
            int register = studenService.register(student);
            System.out.println(register);
        }
   }


    /**
     * 登陆测试
     */
    @Test
    public void login(){
        Student student = new Student();
        student.setStudentid("20181041331");
        student.setPassword(",( .0(/&");
        Student login = studenService.login(student);
        System.out.println(login);
    }


    /**
     * 检查学号是否已存在
     */
    @Test
    public void isExistsUsername(){
        Student student = new Student();
        student.setStudentid("20181041331");
        boolean existsUsername = studenService.isExistsUsername(student);
        System.out.println(existsUsername);
    }


    /**
     * 分页查询
     */
    @Test
    public void page(){

        Page<Student> page = studenService.page(1, 5);
        System.out.println(page);
        List<Student> items = page.getItems();

        for (int i = 0; i <items.size() ; i++) {
            Student student = items.get(i);
            System.out.println(student);
        }
    }


    /**
     *修改学生信息
     */
    @Test
    public void update() throws ParseException {
        Student student = new Student(2,"20181041331","小明","513722199707014394","男",TimeCycle.time("2000-09-07"),"汉","中共党员",
                "20210404_202411_014564_峡谷狂飙_Zxy男朋友.jpg","13600904451","2296877874@qq.com","计算机科学与技术(1)班","计算机科学与技术",
                "数学与计算机学院","福建厦门","李小李","13600904451","四川成都","1234",TimeCycle.time("2018-09-07"),0);
        int update = studenService.update(student);
        System.out.println(update);
    }


    /**
     * 删除学生信息
     *
     */
    @Test
    public void delete(){
        Student student = new Student();
        student.setStudid(23);
        int delete = studenService.delete(student);
        System.out.println(delete);
    }

    /**
     * 查询所以学生信息
     */
    @Test
    public void queryAll(){
        List<Student> students = studenService.queryAll();
        for (int i = 0; i <students.size() ; i++) {
            Student student = students.get(i);
            System.out.println(student);
        }
    }


    /**
     * 根据id查询学生信息
     */
    @Test
    public void queryById(){
        Student student = new Student();
        student.setStudid(1);
        Student student1 = studenService.queryById(student);
        System.out.println(student1);
    }


    /**
     * 测试重置学生密码
     */


    @Test
    public  void resetPassword(){
        Student student = new Student();
        student.setStudentid("20181041331");
        student.setIdnumber("513722199707014394");
        student.setPhone("13600904451");
        Map<String, String> map = studenService.resetPassword(student);
        System.out.println(map);

    }

}
